<!-- HTML header for doxygen 1.8.20-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
	<meta http-equiv="X-UA-Compatible" content="IE=9"/>
	<meta name="generator" content="Doxygen 1.9.4"/>
	<meta name="viewport" content="width=device-width, initial-scale=1"/>
	<title>Raspberry Pi Pico SDK: sem</title>
	<!-- <link href="tabs.css" rel="stylesheet" type="text/css"/> -->
	<script type="text/javascript" src="jquery.js"></script>
	<script type="text/javascript" src="dynsections.js"></script>
	<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
	<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
    <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500&display=swap" rel="stylesheet">
	<link href="doxygen.css" rel="stylesheet" type="text/css" />
	<link href="normalise.css" rel="stylesheet" type="text/css"/>
<link href="main.css" rel="stylesheet" type="text/css"/>
<link href="styles.css" rel="stylesheet" type="text/css"/>
</head>
<body>
	<div class="navigation-mobile">
		<div class="logo--mobile">
			<a href="/"><img src="logo-mobile.svg" alt="Raspberry Pi"></a>
		</div>
		<div class="navigation-toggle">
			<span class="line-1"></span>
			<span class="line-2">
				<p>Menu Toggle</p>
			</span>
			<span class="line-3"></span>
		</div>
	</div>
	<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
		<div class="logo">
			<a href="index.html"> <img src="logo.svg" alt="Raspberry Pi"></a>
			<span style="display: inline-block; margin-top: 10px;">
				v2.0.0
			</span>
		</div>
		<div class="navigation-footer">
			<img src="logo-mobile.svg" alt="Raspberry Pi">
			<a href="https://www.raspberrypi.com/" target="_blank">By Raspberry Pi Ltd</a>
		</div>
<!-- 		<div class="search">
			<form>
				<input type="search" name="search" id="search" placeholder="Search">
				<input type="submit" value="Search">
			</form>
		</div> -->
<!-- Generated by Doxygen 1.9.4 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search",'Search','.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(document).ready(function(){initNavTree('group__sem.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle"><div class="title">sem<div class="ingroups"><a class="el" href="group__high__level.html">High Level APIs</a> &raquo; <a class="el" href="group__pico__sync.html">pico_sync</a></div></div></div>
</div><!--header-->
<div class="contents">

<p>Semaphore API for restricting access to a resource.  
<a href="#details">More...</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="func-members" name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:gab4e56b5ccfacafd2fb17765e702a21ba"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__sem.html#gab4e56b5ccfacafd2fb17765e702a21ba">sem_init</a> (<a class="el" href="structsemaphore.html">semaphore_t</a> *sem, int16_t initial_permits, int16_t max_permits)</td></tr>
<tr class="memdesc:gab4e56b5ccfacafd2fb17765e702a21ba"><td class="mdescLeft">&#160;</td><td class="mdescRight">Initialise a semaphore structure.  <a href="group__sem.html#gab4e56b5ccfacafd2fb17765e702a21ba">More...</a><br /></td></tr>
<tr class="separator:gab4e56b5ccfacafd2fb17765e702a21ba"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gad9e065ef0c0e59309f9bdb5fb74bb7c1"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__sem.html#gad9e065ef0c0e59309f9bdb5fb74bb7c1">sem_available</a> (<a class="el" href="structsemaphore.html">semaphore_t</a> *sem)</td></tr>
<tr class="memdesc:gad9e065ef0c0e59309f9bdb5fb74bb7c1"><td class="mdescLeft">&#160;</td><td class="mdescRight">Return number of available permits on the semaphore.  <a href="group__sem.html#gad9e065ef0c0e59309f9bdb5fb74bb7c1">More...</a><br /></td></tr>
<tr class="separator:gad9e065ef0c0e59309f9bdb5fb74bb7c1"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaeac89066f5fdbde0c7db2718464dcbde"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__sem.html#gaeac89066f5fdbde0c7db2718464dcbde">sem_release</a> (<a class="el" href="structsemaphore.html">semaphore_t</a> *sem)</td></tr>
<tr class="memdesc:gaeac89066f5fdbde0c7db2718464dcbde"><td class="mdescLeft">&#160;</td><td class="mdescRight">Release a permit on a semaphore.  <a href="group__sem.html#gaeac89066f5fdbde0c7db2718464dcbde">More...</a><br /></td></tr>
<tr class="separator:gaeac89066f5fdbde0c7db2718464dcbde"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gab6c128952e4981a95ce2e2d093a8a3ba"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__sem.html#gab6c128952e4981a95ce2e2d093a8a3ba">sem_reset</a> (<a class="el" href="structsemaphore.html">semaphore_t</a> *sem, int16_t permits)</td></tr>
<tr class="memdesc:gab6c128952e4981a95ce2e2d093a8a3ba"><td class="mdescLeft">&#160;</td><td class="mdescRight">Reset semaphore to a specific number of available permits.  <a href="group__sem.html#gab6c128952e4981a95ce2e2d093a8a3ba">More...</a><br /></td></tr>
<tr class="separator:gab6c128952e4981a95ce2e2d093a8a3ba"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaefa22667355703497ae883f68a87aacf"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__sem.html#gaefa22667355703497ae883f68a87aacf">sem_acquire_blocking</a> (<a class="el" href="structsemaphore.html">semaphore_t</a> *sem)</td></tr>
<tr class="memdesc:gaefa22667355703497ae883f68a87aacf"><td class="mdescLeft">&#160;</td><td class="mdescRight">Acquire a permit from the semaphore.  <a href="group__sem.html#gaefa22667355703497ae883f68a87aacf">More...</a><br /></td></tr>
<tr class="separator:gaefa22667355703497ae883f68a87aacf"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga38275bfc4c00e5039028f58860709610"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__sem.html#ga38275bfc4c00e5039028f58860709610">sem_acquire_timeout_ms</a> (<a class="el" href="structsemaphore.html">semaphore_t</a> *sem, uint32_t timeout_ms)</td></tr>
<tr class="memdesc:ga38275bfc4c00e5039028f58860709610"><td class="mdescLeft">&#160;</td><td class="mdescRight">Acquire a permit from a semaphore, with timeout.  <a href="group__sem.html#ga38275bfc4c00e5039028f58860709610">More...</a><br /></td></tr>
<tr class="separator:ga38275bfc4c00e5039028f58860709610"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga0f5a509fb132e8e764795a66773500ad"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__sem.html#ga0f5a509fb132e8e764795a66773500ad">sem_acquire_timeout_us</a> (<a class="el" href="structsemaphore.html">semaphore_t</a> *sem, uint32_t timeout_us)</td></tr>
<tr class="memdesc:ga0f5a509fb132e8e764795a66773500ad"><td class="mdescLeft">&#160;</td><td class="mdescRight">Acquire a permit from a semaphore, with timeout.  <a href="group__sem.html#ga0f5a509fb132e8e764795a66773500ad">More...</a><br /></td></tr>
<tr class="separator:ga0f5a509fb132e8e764795a66773500ad"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga4410f17fc2f35b91e5bcfaf18bcf26ae"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__sem.html#ga4410f17fc2f35b91e5bcfaf18bcf26ae">sem_acquire_block_until</a> (<a class="el" href="structsemaphore.html">semaphore_t</a> *sem, <a class="el" href="group__timestamp.html#ga8b7f3d602cc053f05bacceeacc257ed8">absolute_time_t</a> until)</td></tr>
<tr class="memdesc:ga4410f17fc2f35b91e5bcfaf18bcf26ae"><td class="mdescLeft">&#160;</td><td class="mdescRight">Wait to acquire a permit from a semaphore until a specific time.  <a href="group__sem.html#ga4410f17fc2f35b91e5bcfaf18bcf26ae">More...</a><br /></td></tr>
<tr class="separator:ga4410f17fc2f35b91e5bcfaf18bcf26ae"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga25b473ab6f287e4a6a0c9d0288a0a497"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__sem.html#ga25b473ab6f287e4a6a0c9d0288a0a497">sem_try_acquire</a> (<a class="el" href="structsemaphore.html">semaphore_t</a> *sem)</td></tr>
<tr class="memdesc:ga25b473ab6f287e4a6a0c9d0288a0a497"><td class="mdescLeft">&#160;</td><td class="mdescRight">Attempt to acquire a permit from a semaphore without blocking.  <a href="group__sem.html#ga25b473ab6f287e4a6a0c9d0288a0a497">More...</a><br /></td></tr>
<tr class="separator:ga25b473ab6f287e4a6a0c9d0288a0a497"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<p >Semaphore API for restricting access to a resource. </p>
<p >A semaphore holds a number of available permits. <code>sem_acquire</code> methods will acquire a permit if available (reducing the available count by 1) or block if the number of available permits is 0. <a class="el" href="group__sem.html#gaeac89066f5fdbde0c7db2718464dcbde">sem_release()</a> increases the number of available permits by one potentially unblocking a <code>sem_acquire</code> method.</p>
<p >Note that <a class="el" href="group__sem.html#gaeac89066f5fdbde0c7db2718464dcbde">sem_release()</a> may be called an arbitrary number of times, however the number of available permits is capped to the max_permit value specified during semaphore initialization.</p>
<p >Although these semaphore related functions can be used from IRQ handlers, it is obviously preferable to only release semaphores from within an IRQ handler (i.e. avoid blocking) </p>
<h2 class="groupheader">Function Documentation</h2>
<a id="ga4410f17fc2f35b91e5bcfaf18bcf26ae" name="ga4410f17fc2f35b91e5bcfaf18bcf26ae"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga4410f17fc2f35b91e5bcfaf18bcf26ae">&#9670;&nbsp;</a></span>sem_acquire_block_until()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool sem_acquire_block_until </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structsemaphore.html">semaphore_t</a> *&#160;</td>
          <td class="paramname"><em>sem</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__timestamp.html#ga8b7f3d602cc053f05bacceeacc257ed8">absolute_time_t</a>&#160;</td>
          <td class="paramname"><em>until</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Wait to acquire a permit from a semaphore until a specific time. </p>
<p >This function will block and wait if no permits are available, until the specified timeout time. If the timeout is reached the function will return false, otherwise it will return true.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">sem</td><td>Pointer to semaphore structure </td></tr>
    <tr><td class="paramname">until</td><td>The time after which to return if the sem is not available. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>true if permit was acquired, false if the until time was reached before acquiring. </dd></dl>

</div>
</div>
<a id="gaefa22667355703497ae883f68a87aacf" name="gaefa22667355703497ae883f68a87aacf"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gaefa22667355703497ae883f68a87aacf">&#9670;&nbsp;</a></span>sem_acquire_blocking()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void sem_acquire_blocking </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structsemaphore.html">semaphore_t</a> *&#160;</td>
          <td class="paramname"><em>sem</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Acquire a permit from the semaphore. </p>
<p >This function will block and wait if no permits are available.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">sem</td><td>Pointer to semaphore structure </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="ga38275bfc4c00e5039028f58860709610" name="ga38275bfc4c00e5039028f58860709610"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga38275bfc4c00e5039028f58860709610">&#9670;&nbsp;</a></span>sem_acquire_timeout_ms()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool sem_acquire_timeout_ms </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structsemaphore.html">semaphore_t</a> *&#160;</td>
          <td class="paramname"><em>sem</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint32_t&#160;</td>
          <td class="paramname"><em>timeout_ms</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Acquire a permit from a semaphore, with timeout. </p>
<p >This function will block and wait if no permits are available, until the defined timeout has been reached. If the timeout is reached the function will return false, otherwise it will return true.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">sem</td><td>Pointer to semaphore structure </td></tr>
    <tr><td class="paramname">timeout_ms</td><td>Time to wait to acquire the semaphore, in milliseconds. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>false if timeout reached, true if permit was acquired. </dd></dl>

</div>
</div>
<a id="ga0f5a509fb132e8e764795a66773500ad" name="ga0f5a509fb132e8e764795a66773500ad"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga0f5a509fb132e8e764795a66773500ad">&#9670;&nbsp;</a></span>sem_acquire_timeout_us()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool sem_acquire_timeout_us </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structsemaphore.html">semaphore_t</a> *&#160;</td>
          <td class="paramname"><em>sem</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint32_t&#160;</td>
          <td class="paramname"><em>timeout_us</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Acquire a permit from a semaphore, with timeout. </p>
<p >This function will block and wait if no permits are available, until the defined timeout has been reached. If the timeout is reached the function will return false, otherwise it will return true.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">sem</td><td>Pointer to semaphore structure </td></tr>
    <tr><td class="paramname">timeout_us</td><td>Time to wait to acquire the semaphore, in microseconds. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>false if timeout reached, true if permit was acquired. </dd></dl>

</div>
</div>
<a id="gad9e065ef0c0e59309f9bdb5fb74bb7c1" name="gad9e065ef0c0e59309f9bdb5fb74bb7c1"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gad9e065ef0c0e59309f9bdb5fb74bb7c1">&#9670;&nbsp;</a></span>sem_available()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int sem_available </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structsemaphore.html">semaphore_t</a> *&#160;</td>
          <td class="paramname"><em>sem</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Return number of available permits on the semaphore. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">sem</td><td>Pointer to semaphore structure </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>The number of permits available on the semaphore. </dd></dl>

</div>
</div>
<a id="gab4e56b5ccfacafd2fb17765e702a21ba" name="gab4e56b5ccfacafd2fb17765e702a21ba"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gab4e56b5ccfacafd2fb17765e702a21ba">&#9670;&nbsp;</a></span>sem_init()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void sem_init </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structsemaphore.html">semaphore_t</a> *&#160;</td>
          <td class="paramname"><em>sem</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int16_t&#160;</td>
          <td class="paramname"><em>initial_permits</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int16_t&#160;</td>
          <td class="paramname"><em>max_permits</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Initialise a semaphore structure. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">sem</td><td>Pointer to semaphore structure </td></tr>
    <tr><td class="paramname">initial_permits</td><td>How many permits are initially acquired </td></tr>
    <tr><td class="paramname">max_permits</td><td>Total number of permits allowed for this semaphore </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="gaeac89066f5fdbde0c7db2718464dcbde" name="gaeac89066f5fdbde0c7db2718464dcbde"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gaeac89066f5fdbde0c7db2718464dcbde">&#9670;&nbsp;</a></span>sem_release()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool sem_release </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structsemaphore.html">semaphore_t</a> *&#160;</td>
          <td class="paramname"><em>sem</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Release a permit on a semaphore. </p>
<p >Increases the number of permits by one (unless the number of permits is already at the maximum). A blocked <code>sem_acquire</code> will be released if the number of permits is increased.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">sem</td><td>Pointer to semaphore structure </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>true if the number of permits available was increased. </dd></dl>

</div>
</div>
<a id="gab6c128952e4981a95ce2e2d093a8a3ba" name="gab6c128952e4981a95ce2e2d093a8a3ba"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gab6c128952e4981a95ce2e2d093a8a3ba">&#9670;&nbsp;</a></span>sem_reset()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void sem_reset </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structsemaphore.html">semaphore_t</a> *&#160;</td>
          <td class="paramname"><em>sem</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int16_t&#160;</td>
          <td class="paramname"><em>permits</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Reset semaphore to a specific number of available permits. </p>
<p >Reset value should be from 0 to the max_permits specified in the init function</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">sem</td><td>Pointer to semaphore structure </td></tr>
    <tr><td class="paramname">permits</td><td>the new number of available permits </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="ga25b473ab6f287e4a6a0c9d0288a0a497" name="ga25b473ab6f287e4a6a0c9d0288a0a497"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga25b473ab6f287e4a6a0c9d0288a0a497">&#9670;&nbsp;</a></span>sem_try_acquire()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool sem_try_acquire </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structsemaphore.html">semaphore_t</a> *&#160;</td>
          <td class="paramname"><em>sem</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Attempt to acquire a permit from a semaphore without blocking. </p>
<p >This function will return false without blocking if no permits are available, otherwise it will acquire a permit and return true.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">sem</td><td>Pointer to semaphore structure </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>true if permit was acquired. </dd></dl>

</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->

	<script src="main.js"></script>
</body>
</html>